#pragma once
#include "hy_includes.h"
#include "hy_net/hy_network_message.h"

inline int	get_json_int( Json::Value& v, const char* c )
{
	if( !v[c].empty() )
	{
		if( v[c].isInt() )
			return v[c].asInt();
	}
	return 0;
}

inline double get_json_double( Json::Value& v, const char* c )
{
	Json::Value& cv = v[c];
	if( !cv.empty() )
	{
		if( cv.isDouble() )
			return cv.asDouble();
		if( cv.isInt() )
			return (double)cv.asInt();
	}
	return 0.0;
}

inline std::string get_json_string( Json::Value& v, const char* c )
{
	if( !v[c].empty() )
	{
		if( v[c].isString() )
			return v[c].asString();
	}
	return "";
}

int random_int( int begin, int end );

//class hy_network_message;
bool send_player_list_msg( int_vec& iv, hy_network_message* nm );

uint64			get_cur_system_second();

class hy_common_func
{
	//static bool read_json( const char* js_name, Json::Value& js_value );
};